<template>
  <div>
    <!-- 导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 菜单组 -->
    <el-row :gutter="10">
      <el-col :span="3" :offset="6">
        <el-button type="primary" @click="insertShow = true">添加用户</el-button>
      </el-col>
      <el-col :span="3">
        <el-upload
          class="filter-item"
          name="excelFile"
          :action="uploadUrl()"
          :on-error="uploadFalse"
          :on-success="uploadSuccess"
          :before-upload="beforeAvatarUpload"
          :limit="1"
          accept=".xlsx, .xls"
          :show-file-list="false"
          :file-list="fileList"
          ref="uploadRef"
        >
          <el-button type="success">导入用户</el-button>
        </el-upload>
      </el-col>
      <el-col :span="3">
        <el-button type="warning" @click="downloadDemo">模板导出</el-button>
      </el-col>
      <el-col :span="3">
        <el-button type="danger" @click="deleteSelection('UserTableRef')">批量删除</el-button>
      </el-col>
    </el-row>
    <el-row></el-row>
    <!-- 查询框 -->
    <el-form
      ref="UserSearchFormRef"
      :model="UserSearchForm"
      label-width="80px"
      label-position="top"
      :inline="true"
      class="demo-form-inline"
    >
      <el-col :span="4">
        <el-form-item label="登录名">
          <el-input placeholder="空" v-model="UserSearchForm.username" clearable></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="4">
        <el-form-item label="真实姓名">
          <el-input placeholder="空" v-model="UserSearchForm.realname" clearable></el-input>
        </el-form-item>
      </el-col>

      <el-col :span="4">
        <el-form-item label="所在科室">
          <el-select v-model="UserSearchForm.deptid" placeholder="空" filterable>
            <el-option label="空" :value="null"></el-option>
            <el-option
              v-for="item in DepartmentArray"
              :key="item.id"
              :label="item.deptname"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="4">
        <el-form-item label="用户类别">
          <el-select v-model="UserSearchForm.usetype" placeholder="空" filterable>
            <el-option label="空" :value="null"></el-option>
            <el-option
              v-for="item in UserTypeArray"
              :key="item.id"
              :label="item.usertype"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="4">
        <el-form-item label="医生职称">
          <el-select v-model="UserSearchForm.doctitleid" placeholder="空" filterable>
            <el-option label="空" :value="null"></el-option>
            <el-option
              v-for="item in DocTitleArray"
              :key="item.id"
              :label="item.constantname"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="4">
        <el-form-item style="margin-top:50px;margin-left:20px">
          <el-button type="success" @click="searchUserList">查询</el-button>
        </el-form-item>
      </el-col>
    </el-form>
    <!-- 显示列表 -->
    <el-table
      ref="UserTableRef"
      :data="UserData"
      fit
      empty-text
      tooltip-effect="dark"
      border
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column prop="username" label="用户名" fixed sortable></el-table-column>
      <el-table-column prop="realname" label="真实姓名" sortable></el-table-column>
      <el-table-column prop="password" label="密码" show-overflow-tooltip></el-table-column>
      <el-table-column
        prop="usetype"
        label="用户类型"
        show-overflow-tooltip
        :formatter="userTypeFormat"
      ></el-table-column>
      <el-table-column prop="doctitleid" label="医生职称" show-overflow-tooltip>
        <template slot-scope="scope">
          <div v-if="scope.row.constantitem!=null">{{ scope.row.constantitem.constantname }}</div>
          <div v-else>无</div>
        </template>
      </el-table-column>
      <el-table-column prop="isscheduling" label="是否参与排班" show-overflow-tooltip></el-table-column>
      <el-table-column prop="deptid" label="所在科室" show-overflow-tooltip>
        <template slot-scope="scope">{{ scope.row.department.deptname }}</template>
      </el-table-column>
      <el-table-column prop="registleid" label="挂号级别" show-overflow-tooltip>
        <template slot-scope="scope">
          <div v-if="scope.row.registlevel!=null">{{ scope.row.registlevel.registname }}</div>
          <div v-else>无</div>
        </template>
      </el-table-column>
      <el-table-column label="操作" fixed="right">
        <template slot-scope="scope">
          <el-button type="primary" icon="el-icon-edit" @click="updateDialog(scope.row)" circle></el-button>
          <el-button type="danger" icon="el-icon-delete" @click="deleteUser(scope.row)" circle></el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页条 -->
    <div class="block" style="margin-top:1rem;margin-left:20%">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :total="pageInfo.total"
        :current-page="pageInfo.pageNum"
        :page-sizes="[8,16,32,50,100]"
        :page-size="pageInfo.pageSize"
        layout=" prev, pager, next, jumper,total, sizes"
      ></el-pagination>
    </div>
    <!-- 添加弹窗 -->
    <el-dialog title="添加用户" :visible.sync="insertShow" width="40%" center status-icon>
      <el-form
        ref="UserInsertFormRef"
        :model="UserInsertForm"
        :rules="GlobalFormrules"
        label-width="25%"
        label-position="left"
        class="demo-form-inline"
        :lock-scroll="true"
        :append-to-body="true"
      >
        <el-form-item label="登录名" prop="username">
          <el-input placeholder="空" v-model="UserInsertForm.username" style="width:80%" clearable></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input placeholder="空" v-model="UserInsertForm.password" style="width:80%" clearable></el-input>
        </el-form-item>
        <el-form-item label="真实姓名" prop="realname">
          <el-input placeholder="空" v-model="UserInsertForm.realname" style="width:80%" clearable></el-input>
        </el-form-item>
        <el-form-item label="用户类别" prop="usetype">
          <el-select v-model="UserInsertForm.usetype" filterable>
            <el-option
              v-for="item in UserTypeArray"
              :key="item.id"
              :label="item.usertype"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="医生职称" prop="doctitleid" v-if="usetypevaild_i">
          <el-select v-model="UserInsertForm.doctitleid" filterable>
            <el-option
              v-for="item in DocTitleArray"
              :key="item.id"
              :label="item.constantname"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否参与排班" prop="isscheduling" v-if="usetypevaild_i">
          <template>
            <el-radio label="是" v-model="UserInsertForm.isscheduling">是</el-radio>
            <el-radio label="否" v-model="UserInsertForm.isscheduling">否</el-radio>
          </template>
        </el-form-item>
        <el-form-item label="所在科室" prop="deptid">
          <el-select v-model="UserInsertForm.deptid" filterable>
            <el-option
              v-for="item in DepartmentArray"
              :key="item.id"
              :label="item.deptname"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="挂号级别" prop="registleid" v-if="usetypevaild_i">
          <el-select v-model="UserInsertForm.registleid" filterable>
            <el-option
              v-for="item in RegistlevelArray"
              :key="item.id"
              :label="item.registname"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="UserInsertFormSubmit('UserInsertFormRef')">添加</el-button>
        <el-button @click="resetForm('UserInsertFormRef')">重置</el-button>
      </span>
    </el-dialog>

    <!-- 修改弹窗 -->
    <el-dialog
      title="修改用户"
      :visible.sync="updateShow"
      width="30%"
      center
      status-icon
      :lock-scroll="true"
      :append-to-body="true"
    >
      <el-form
        ref="UserUpdateFormRef"
        :model="UserUpdateForm"
        label-width="25%"
        :rules="GlobalFormrules"
        label-position="left"
        class="demo-form-inline"
      >
        <el-form-item label="登录名" prop="username">
          <el-input placeholder="空" v-model="UserUpdateForm.username" style="width:80%" clearable></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input placeholder="空" v-model="UserUpdateForm.password" style="width:80%" clearable></el-input>
        </el-form-item>
        <el-form-item label="真实姓名" prop="realname">
          <el-input placeholder="空" v-model="UserUpdateForm.realname" style="width:80%" clearable></el-input>
        </el-form-item>
        <el-form-item label="用户类别" prop="usetype">
          <el-select v-model="UserUpdateForm.usetype" filterable>
            <el-option
              v-for="item in UserTypeArray"
              :key="item.id"
              :label="item.usertype"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="医生职称" prop="doctitleid" v-if="usetypevaild_u">
          <el-select v-model="UserUpdateForm.doctitleid" filterable>
            <el-option
              v-for="item in DocTitleArray"
              :key="item.id"
              :label="item.constantname"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否参与排班" prop="isscheduling" v-if="usetypevaild_u">
          <template>
            <el-radio label="是" v-model="UserUpdateForm.isscheduling">是</el-radio>
            <el-radio label="否" v-model="UserUpdateForm.isscheduling">否</el-radio>
          </template>
        </el-form-item>
        <el-form-item label="所在科室" prop="deptid">
          <el-select v-model="UserUpdateForm.deptid" filterable>
            <el-option
              v-for="item in DepartmentArray"
              :key="item.id"
              :label="item.deptname"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="挂号级别" prop="registleid" v-if="usetypevaild_u">
          <el-select v-model="UserUpdateForm.registleid" filterable>
            <el-option
              v-for="item in RegistlevelArray"
              :key="item.id"
              :label="item.registname"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="UserUpdateFormSubmit('UserUpdateFormRef')">保存</el-button>
        <el-button @click="resetForm('UserUpdateFormRef')">重置</el-button>
      </span>
    </el-dialog>
    <!-- 上传信息错误详情弹窗 -->
    <!-- 错误信息展示弹窗 -->
    <el-dialog
      title="文件不规范列表"
      :visible.sync="errorListShow"
      width="60%"
      center
      status-icon
      :lock-scroll="true"
      :append-to-body="true"
    >
      <el-alert :title="item" type="error" v-for="(item,index) in errorList" :key="index"></el-alert>

      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="errorListShow=false">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    //用户名验证
    var validusername = async (rule, value, callback) => {
      let queryname = "";
      if (this.updateShow) {
        queryname = this.UserUpdateForm.username;
      }
      if (this.insertShow) {
        queryname = this.UserInsertForm.username;
      }
      const { data: res } = await this.$http.post("user/findValidUserName", {
        username: queryname,
      });
      if (res.meta.status == 200) {
        callback(new Error("用户名重复"));
      }
      callback();
    };
    return {
      // 修改弹窗是否展开
      updateShow: false,
      //添加弹窗是否展开
      insertShow: false,
      //文件上传导入失败弹窗
      errorListShow: false,
      //文件上传规范错误列表
      errorList: [],
      //文件上传成功文件列表
      fileList: [],
      // 用户类型数组
      UserTypeArray: [
        { id: 1, usertype: "医院管理员" },
        { id: 2, usertype: "挂号收费员" },
        { id: 3, usertype: "门诊医生" },
        { id: 4, usertype: "医技医生" },
        { id: 5, usertype: "药房操作员" },
        { id: 6, usertype: "财务管理员" },
      ],
      // 医生职称列表
      DocTitleArray: [],
      // 科室列表
      DepartmentArray: [],
      // 挂号级别列表
      RegistlevelArray: [],
      // 用户查询
      UserSearchForm: {
        username: "",
        realname: "",
        usetype: null,
        doctitleid: null,
        deptid: null,
      },
      //用户显示数据
      UserData: [],
      // 添加用户
      UserInsertForm: {
        username: "",
        password: "",
        realname: "",
        usetype: null,
        doctitleid: null,
        isscheduling: "否",
        deptid: null,
        registleid: null,
      },
      // 添加用户重置信息
      UserInsertResetInfo: {
        username: "",
        password: "",
        realname: "",
        usetype: null,
        doctitleid: null,
        isscheduling: "否",
        deptid: null,
        registleid: null,
      },
      // 修改用户
      UserUpdateForm: {
        id: null,
        username: "",
        password: "",
        realname: "",
        usetype: null,
        doctitleid: null,
        isscheduling: "否",
        deptid: null,
        registleid: null,
      },
      //修改页面重置信息
      UserUpdateResetInfo: {},
      // 页面信息
      pageInfo: {
        pageNum: 1,
        pageSize: 8,
        total: 0,
      },
      //验证规则
      GlobalFormrules: {
        username: [
          { required: true, message: "请输入用户登录名", trigger: "blur" },
          {
            min: 3,
            max: 64,
            message: "长度在 3 到 64 个字符",
            trigger: "blur",
          },
          { validator: validusername, trigger: "blur" },
        ],
        realname: [
          { required: true, message: "请输入用户真实姓名", trigger: "blur" },
          {
            min: 2,
            max: 64,
            message: "长度在 2 到 64 个字符",
            trigger: "blur",
          },
        ],
        password: [
          { required: true, message: "请输入用户密码", trigger: "blur" },
          {
            min: 3,
            max: 64,
            message: "长度在 3 到 64 个字符",
            trigger: "blur",
          },
        ],

        usetype: [
          { required: true, message: "请选择用户类别", trigger: "change" },
        ],
        doctitleid: [
          { required: true, message: "请选择医生职称", trigger: "change" },
        ],
        deptid: [{ required: true, message: "请选择科室", trigger: "change" }],
        registleid: [
          { required: true, message: "请选择挂号等级", trigger: "change" },
        ],
      },
      //多选列表数组
      multipleSelection: [],
    };
  },
  created() {
    // 查询用户列表
    this.searchUserList();
    // 查询医生职称列表
    this.searchDocTitleList();
    // 查询科室列表
    this.searchDepartmentList();
    //  查询挂号级别列表
    this.searchRegistlevelList();
  },
  methods: {
    //修改弹窗渲染
    async updateDialog(row) {
      this.updateShow = true;
      const { data: res } = await this.$http.post("user/findUserById", {
        id: row.id,
      });
      if (res.meta.status !== 200) {
        return this.$message.error("获取用户信息失败，请刷新页面");
      }

      this.UserUpdateForm = res.user;
      //拷贝数据，不拷贝引用
      this.UserUpdateResetInfo = Object.assign({}, res.user);
    },
    //添加表单提交
    UserInsertFormSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.saveOneUser(formName);
        } else {
          this.$message.error("验证失败");
          return false;
        }
      });
    },

    //修改表单提交
    UserUpdateFormSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.updateuserById(formName);
        } else {
          this.$message.error("验证失败");
          return false;
        }
      });
    },
    //表单重置
    resetForm(formName) {
      if (formName == "UserInsertFormRef") {
        //拷贝数据，不拷贝引用
        this.UserInsertForm = Object.assign({}, this.UserInsertResetInfo);
      }
      if (formName == "UserUpdateFormRef") {
        //拷贝数据，不拷贝引用
        this.UserUpdateForm = Object.assign({}, this.UserUpdateResetInfo);
      }
    },
    //删除用户
    deleteUser(row) {
      this.$confirm("此操作将删除该用户信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "error",
      })
        .then(async () => {
          const { data: res } = await this.$http.post("user/deleteUserById", {
            id: row.id,
          });
          if (res.meta.status !== 200) {
            return this.$message.error("删除失败");
          }
          this.$message({
            type: "success",
            message: "删除成功",
          });
          this.searchUserList();
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //批量删除选中的用户信息
    deleteSelection(formname) {
      if (this.multipleSelection.length == 0) {
        this.$message.info("请选中一行或多行数据");
        return;
      }
      this.$confirm("此操作将删除您选中的用户信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "error",
      })
        .then(async () => {
          const { data: res } = await this.$http.post("user/deleteUserBatch", {
            idArray: this.multipleSelection,
          });
          if (res.meta.status !== 200) {
            return this.$message.error("删除失败");
          }
          this.$message({
            type: "success",
            message: "删除成功",
          });
          this.pageInfo.pageNum = 1;
          this.searchUserList();
          this.multipleSelection = [];
          this.$refs[formname].clearSelection();
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //多选选中用户id
    handleSelectionChange(val) {
      this.multipleSelection = [];
      for (let index in val) {
        this.multipleSelection[index] = val[index].id;
      }

      // console.log(this.multipleSelection)
    },
    //查询用户列表
    async searchUserList() {
      const { data: res } = await this.$http.post("user/listUsers", {
        username: this.UserSearchForm.username,
        realname: this.UserSearchForm.realname,
        usetype: this.UserSearchForm.usetype,
        doctitleid: this.UserSearchForm.doctitleid,
        deptid: this.UserSearchForm.deptid,
        pageNum: this.pageInfo.pageNum,
        pageSize: this.pageInfo.pageSize,
      });
      if (res.meta.status !== 200) {
        return this.$message.error("获取用户列表失败");
      }
      this.UserData = res.info.list;
      this.pageInfo.pageNum = res.info.pageNum;
      this.pageInfo.pageSize = res.info.pageSize;
      this.pageInfo.total = res.info.total;
      console.log(res);
      // console.log(this.UserData)
    },
    //查询医生职称列表
    async searchDocTitleList() {
      const { data: res } = await this.$http.post(
        "constantitem/findListByConstanttypeid",
        {
          id: 8,
        }
      );
      if (res.meta.status !== 200) {
        return this.$message.error("获取医生职称列表失败");
      }
      this.DocTitleArray = res.list;
      // console.log(res);
    },

    //查询科室列表
    async searchDepartmentList() {
      const { data: res } = await this.$http.post(
        "department/findAllDepartment",
        {}
      );
      if (res.meta.status !== 200) {
        return this.$message.error("获取科室列表失败");
      }
      this.DepartmentArray = res.list;
      // console.log(res);
    },
    //查询挂号类别列表
    async searchRegistlevelList() {
      const {
        data: res,
      } = await this.$http.post("registlevel/findAllRegistlevel", { id: null });
      if (res.meta.status !== 200) {
        return this.$message.error("获取挂号级别列表失败");
      }
      this.RegistlevelArray = res.list;
      // console.log(res);
    },
    //添加一个用户
    async saveOneUser(formName) {
      const { data: res } = await this.$http.post("user/saveOneUser", {
        username: this.UserInsertForm.username,
        password: this.UserInsertForm.password,
        realname: this.UserInsertForm.realname,
        usetype: this.UserInsertForm.usetype,
        doctitleid: this.UserInsertForm.doctitleid,
        isscheduling: this.UserInsertForm.isscheduling,
        deptid: this.UserInsertForm.deptid,
        registleid: this.UserInsertForm.registleid,
      });
      if (res.meta.status !== 200) {
        return this.$message.error("添加新用户失败");
      }
      this.$message.success("添加新用户成功");
      this.insertShow = false;
      this.resetForm(formName);
      this.searchUserList();
      // console.log(res);
    },
    //修改用户信息
    async updateuserById(formName) {
      if (this.UserUpdateForm.id == null) {
        return this.$message.error("保存用户信息失败");
      }
      const { data: res } = await this.$http.post("user/updateById", {
        id: this.UserUpdateForm.id,
        username: this.UserUpdateForm.username,
        password: this.UserUpdateForm.password,
        realname: this.UserUpdateForm.realname,
        usetype: this.UserUpdateForm.usetype,
        doctitleid: this.UserUpdateForm.doctitleid,
        isscheduling: this.UserUpdateForm.isscheduling,
        deptid: this.UserUpdateForm.deptid,
        registleid: this.UserUpdateForm.registleid,
      });
      if (res.meta.status !== 200) {
        return this.$message.error("保存用户信息失败");
      }
      this.$message.success("保存用户信息成功");
      this.updateShow = false;
      this.resetForm(formName);
      this.searchUserList();
      // console.log(res);
    },
    //文件上传成功
    uploadSuccess(response, file, fileList) {
      console.log(response);
      if (response.meta.status == 200) {
        this.$refs.uploadRef.clearFiles();
        this.pageInfo.pageNum = 1;
        this.searchUserList();
        this.$message({
          message: "导入成功",
          type: "success",
        });
      } else if (response.flag == 0 && response.errorList != null) {
        this.$refs.uploadRef.clearFiles();
        this.errorList = response.errorList;
        this.errorListShow = true;
        this.$message({
          message: "文件存在不规范的项目",
          type: "error",
        });
      } else {
        this.$refs.uploadRef.clearFiles();
        this.$message({
          message: "导入失败",
          type: "error",
        });
      }
    },
    uploadFalse(response, file, fileList) {
      this.$message({
        message: "文件上传失败！",
        type: "error",
      });
    },
    // 上传前对文件的大小的判断
    beforeAvatarUpload(file) {
      const extension = file.name.split(".")[1] === "xls";
      const extension2 = file.name.split(".")[1] === "xlsx";
      const isLt2M = file.size / 1024 / 1024 < 10;
      if (!extension && !extension2) {
        this.$message({
          message: "上传模板只能是 xls、xlsx格式!",
          type: "error",
        });
      }
      if (!isLt2M) {
        console.log("上传模板大小不能超过 10MB!");
        this.$message({
          message: "上传模板大小不能超过 10MB!",
          type: "error",
        });
      }
      return extension || extension2 || extension3 || (extension4 && isLt2M);
    },
    uploadUrl() {
      return "http://localhost:8085/his/user/saveUserBatch";
    },
    //分页函数 查询条数改变
    handleSizeChange(size) {
      this.pageInfo.pageNum = 1;
      this.pageInfo.pageSize = size;
      this.searchUserList();
    },
    //分页函数 查询页数改变
    handleCurrentChange(page) {
      this.pageInfo.pageNum = page;
      this.searchUserList();
    },
    // 用户类型格式化
    userTypeFormat(row) {
      if (row == null) {
        return;
      }
      for (const uu of this.UserTypeArray) {
        if (uu.id == row.usetype) {
          return uu.usertype;
        }
        if (row.usetype == 0) {
          return "无";
        }
      }
    },
    //文件下载
    downloadDemo() {
      let url = "/user/downloadExcel";
      let ttime = new Date();
      let suftime = ttime.getTime();
      this.exportData(url, null, "用户模板_" + suftime);
    },
    //文件下载
    exportData(url, data, fileName) {
      this.$http({
        method: "POST",
        url: url,
        data: data,
        responseType: "blob",
      })
        .then((response) => {
          if (!response) {
            return;
          }
          const blob = new Blob([response.data]);
          if (window.navigator && window.navigator.msSaveOrOpenBlob) {
            navigator.msSaveBlob(blob, fileName);
          } else {
            let u = window.URL.createObjectURL(response.data);
            let aLink = document.createElement("a");
            aLink.style.display = "none";
            aLink.href = u;
            aLink.setAttribute("download", fileName + ".xlsx");
            document.body.appendChild(aLink);
            aLink.click();
            document.body.removeChild(aLink);
            window.URL.revokeObjectURL(u);
          }
        })
        .catch((error) => {
          throw error;
        });
    },
  },
  computed: {
    // 用户类型是否是门诊医生验证_添加
    usetypevaild_i() {
      if (this.UserInsertForm.usetype == 3) {
        return true;
      }
      return false;
    },
    // 用户类型是否是门诊医生验证_修改
    usetypevaild_u() {
      if (this.UserUpdateForm.usetype == 3) {
        return true;
      }
      return false;
    },
  },
};
</script>
<style lang="less" scoped>
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
//---表格文本居中---
/deep/.el-table th > .cell {
  text-align: center;
}
/deep/.el-table .cell {
  text-align: center;
}
//---表格文本居中---
</style>

